﻿using System;
using EPiServer;
using EPiServer.Core;

namespace ElencySolutions.MultipleProperty
{
    using System.Web;
    using System.Web.Hosting;
    using EPiServer.PlugIn;

    /// <summary>
    /// Register resource class
    /// </summary>
    internal class RegisterResources : PlugInAttribute
    {

        #region Static methods

        /// <summary>
        /// Initialises VPP mappings
        /// </summary>
        public static void Start()
        {
            RegisterVppResources();
            //DataFactory.Instance.LoadedPage += LoadedPage;
        }

        //private static void LoadedPage(object sender, PageEventArgs e)
        //{
        //    PageData page = e.Page;

        //    if (page == null)
        //        return;

        //    foreach (PropertyData propertyData in page.Property)
        //    {
        //        if (propertyData.Value == null) 
        //            continue;

        //        Type type = propertyData.GetType();

        //        if (type.BaseType != null && type.BaseType.FullName.Contains("ElencySolutions.MultipleProperty.MultiplePropertyBase"))
        //            MultiplePropertyHelper.HandleXhtmlStringPropertyTypes(propertyData.Value);
        //    }
        //}

        /// <summary>
        /// Registers Vpp resources
        /// </summary>
        private static void RegisterVppResources()
        {
            if (HttpContext.Current == null)
                return;

            HostingEnvironment.RegisterVirtualPathProvider(new ResourcePathProvider("/util/ElencySolutionsMultipleProperty/MultiplePropertyCopyProperty.aspx", "ElencySolutions.MultipleProperty.Edit.MultiplePropertyCopyProperty.aspx", false));
        }

        #endregion Static methods

    }
}
